package com.example.demo.util;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

public class PatientNum {
    public static void main(String[] args) throws FileNotFoundException {
        String[] headerName = {"push_json","result"};
        String[] headerKey = {"pushJson","result"};
        File file = new File("D:\\p.xlsx");
        List<Map<String, String>> resultlist = ExcelUtils2.praseExcel(new FileInputStream(file),headerName,headerKey);
        Set<String> set = resultlist.stream().map(pushInfoRecordVO -> {
            String result = pushInfoRecordVO.get("result");
            String patientIdCardNum = null;
            if (StringUtils.isNotBlank(result) && result.contains("成功")) {
                String pushJson = pushInfoRecordVO.get("pushJson");
                JSONObject jsonObject = JSONObject.parseObject(pushJson);
                patientIdCardNum = jsonObject.getString("patientIdcardNum");
            }
            return patientIdCardNum;
        }).filter(Objects::nonNull).collect(Collectors.toSet());
        System.out.println("patientNum:"+set.size());
    }

}
